package cn.kgc.crowdfundingadminspringboot2.controller;

import cn.kgc.crowdfundingadminspringboot2.common.ResultEntity;
import cn.kgc.crowdfundingadminspringboot2.pojo.Message;
import cn.kgc.crowdfundingadminspringboot2.service.MessageService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

@Controller
@RequestMapping("/message")
public class MessageController {

    @Resource
    MessageService service;
    @RequestMapping("/query/to/all")
    @ResponseBody
    public ResultEntity queryAll(){
        List<Message> messages = service.queryAll();
        return  ResultEntity.successWithoutData(messages);
    }
    @RequestMapping("/update")
    @ResponseBody
    public ResultEntity update(Message message){
        service.update(message);
        return ResultEntity.successWithoutData();
    }


}
